APEX スライダー形状の Control を作成する
2024-07-14 #Blog #ApexJoy
https://gyazo.com/39ead73047f90926361c677d1602e962
APEX による Rigging で [0, 1] の範囲を持つような Slider の Control を作成する方法
Blend Shape や FK<->IK 操作したりで使いたい
Project: apex-kinefx-joy/apex-blendshape (20.5.278 / 2024-07-15)
Abstract Controls を使用する
https://gyazo.com/8ade4edd91a5b62eb1a503945df9cbaa https://gyazo.com/fabe317c5162d725818e0e9ceb84c8a2
H20.5 で追加された ikfkblend や blendshape (Rig component) ではこのような X 方向にマウスでドラッグできる Control が自動で作成される
このコントロールのことを Abstract controls と呼ぶ (minami110.icon H20 からあったぽいけど気づかなかった..)
追加方法
https://gyazo.com/6b8ad015ae347dc3b54042432dbb6e25
AbstractControl APEX を追加して, parms の引数に指した軸の操作が可能になる
最小値/最大値の制限
https://gyazo.com/5b3a33d3430874f7b361f148e3bb3a7c
APEX Configure Controls SOP.iconAPEX Configure Controls SOP で値の制限をいれることができる
↓ はドキュメントに書いているやり方 (H20.5 だと面倒くさい)
https://gyazo.com/3f0c2e3d9e2bc0de6c410806d1063765
Rig Node の d@properties['control']['parms'] に 範囲の設定をいれる
詳細は APEX graphs を参考
📖 Abstract Control 動いてほしい
https://gyazo.com/39ead73047f90926361c677d1602e962
AbstractControl は xform の入力を取れるので動く見た目がほしければ動かせる
https://gyazo.com/6db2aa603e406965adba5dd0ce6e22ff
コンセプトは 親の xform を同じ parms の入力を使って pretranslate する感じ
code:component_blendshape_abst_ctrl_move.py
# Inputs
names = BindInput("")
scale = BindInput(1.0)
# Split inputs (e.g. "Foo Bar" => Foo, Bar)
name_array = apex.string.split(names)
# Foreach inputs
for bs_name in name_array:
# Finds blendshape control nodes
node_abst = graph.findNode(f"blendshape_{bs_name}_abst")
node_base = graph.findNode(f"blendshape_{bs_name}")
# Create new nodes
node_pretranslate = graph.addNode(
f"pretranslate_blendshape_{bs_name}_abst",
'transform::Pretranslate<Matrix4>')
node_floattovec3= graph.addNode(
f"floattovec3_{bs_name}",
'FloatToVector3')
node_mul = graph.addNode(
"multiply",
"Multiply<Float>")
node_mul.setParms({"a": scale})
# Connect
node_base.xform_out.connect(node_pretranslate.matrix_in)
node_pretranslate.result_out.connect(node_abst.xform_in)
node_floattovec3.vector_out.connect(node_pretranslate.delta_in)
node_mul.result.connect(node_floattovec3.x)
# Get parm
port_parm_inx = node_abst.x_in.promoted()
port_parm_inx.connect(node_mul.b)
https://gyazo.com/01ca6da3788d6319584a6284aea6c996
blendshape (Rig component) で生成される Abstract control を動くようにする APEX Script の例
スペース区切りで Blend Shape の名前を指定する, scale はスライダの移動量 1m x scale の計算に使われる